package com.gaogzhen.service.impl;

import com.gaogzhen.domain.SysRole;
import com.gaogzhen.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gaogzhen.mapper.SysMenuMapper;
import com.gaogzhen.domain.SysMenu;
import com.gaogzhen.service.SysMenuService;
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService{

    @Autowired
    private SysRoleService sysRoleService;

    @Autowired
    private SysMenuMapper sysMenuMapper;


    @Override
    public List<SysMenu> getMenusByUserId(Long userId) {
        // 0、查询用户角色
        if (sysRoleService.isAdminRole(userId)) {
            // 1、如果用户为超级管理员，获取全部菜单
            return sysMenuMapper.selectAll();
        }
        // 2、不是超级管理员,通过用户角色关联查询菜单列表
        return sysMenuMapper.selectMenusByUserId(userId);
    }
}
